<template>
  <div :class="{ daohang, guding: duflag }" ref="daohang">
    <div class="dao">
      <div class="dao-item1">
        <div v-for="(item, index) in daohang" :key="index">
          <span v-if="item.flag" class="sp">
            &nbsp; &nbsp;&nbsp; &nbsp;
            <span v-if="item.zflag" class="iconfont icon-bilibili-line"></span>
            <span v-if="item.sflag" class="iconfont icon-shouji"></span>
          </span>
          {{ item.dh }}
        </div>
      </div>
      <div class="dao-item2">
        <input type="text" placeholder="古偶剧到底怎么啦？" />
        <div class="serch"><span class="iconfont icon-fangdajing"></span></div>
      </div>
      <div class="dao-item3">
        <div class="touimg">
          <img src="../../../../assets/img/head/touxiang0.jpg" alt="" />
        </div>
        <div class="huiyuan">
          <div v-for="(item, index) in huiyuan" :key="index">
            {{ item.hy }}
            <div class="mianbao" v-if="item.num">{{ item.num }}</div>
          </div>
        </div>
        <div class="tougao">
          <div>投稿</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      daohang: [
        {
          dh: "主站",
          zflag: true,
          flag: true,
        },
        {
          dh: "番剧",
        },
        {
          dh: "游戏中心",
        },
        {
          dh: "直播",
        },
        {
          dh: "会员购",
        },
        {
          dh: "漫画",
        },
        {
          dh: "国创动漫",
        },
        {
          dh: "下载App",
          sflag: true,
          flag: true,
        },
      ],
      huiyuan: [
        {
          hy: "大会员",
        },
        {
          hy: "消息",
          num: 53,
        },
        {
          hy: "收藏",
        },
        {
          hy: "历史",
        },
        {
          hy: "创作中心",
        },
      ],
      duflag: false,
    };
  },
  mounted() {
    window.addEventListener("scroll", this.handleScroll, true);
  },
  methods: {
    handleScroll(e) {
      var scrollTop = parseInt(
        e.target.documentElement.scrollTop || e.target.body.scrollTop
      );
      if (scrollTop > 10) {
        this.duflag = true;
      } else {
        this.duflag = false;
      }
    },
  },
};
</script>

<style lang="scss">
.daohang {
  position: absolute;
  top: 2px;
  left: 0px;
  width: 100%;
  height: 50px;
  // background-color: lime;
  z-index: 10;
  font-size: 14px;
  color: white;
  .dao {
    width: 100%;
    height: 100%;
    display: flex;
    .dao-item1 {
      flex: 4;
      min-width: 500px;
      // background-color: magenta;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0px 20px;
      box-sizing: border-box;
      div {
        // color: white;
        .sp {
          position: relative;
          span {
            position: absolute;
            top: 50%;
            left: 4px;
            transform: translateY(-50%);
            font-size: 20px;
          }
        }
      }
      div:hover {
        cursor: pointer;
      }
    }
    .dao-item2 {
      flex: 5;
      // background-color: pink;
      display: flex;
      align-items: center;
      input {
        flex: 1;
        height: 36px;
        outline: none;
        border: none;
        padding-left: 16px;
        font-size: 14px;
        border-radius: 5px 0px 0px 5px;
      }
      .serch {
        // flex: 1;
        background-color: #e7e7e7;
        height: 36px;
        width: 40px;
        border-radius: 0px 5px 5px 0px;
        position: relative;
        span {
          position: absolute;
          top: 50%;
          left: 50%;
          font-weight: 700;
          transform: translate(-50%, -50%);
        }
        span:hover {
          color: #00a1d6;
        }
      }
    }
    .dao-item3 {
      flex: 4;
      min-width: 500px;
      display: flex;
      justify-content: space-between;
      padding: 0px 20px;
      box-sizing: border-box;
      .touimg {
        flex: 1;
        // background-color: cyan;
        display: flex;
        justify-content: center;
        align-items: center;
        img {
          border-radius: 50%;
          width: 36px;
          height: 36px;
        }
      }
      .huiyuan {
        flex: 5;
        // background-color: tan;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0px 20px;
        box-sizing: border-box;
        div {
          // color: white;
          position: relative;
          .mianbao {
            position: absolute;
            top: -12px;
            right: -10px;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            color: white;
            font-size: 12px;
            text-align: center;
            line-height: 20px;
            background-color: #fa5a57;
          }
        }
        div:hover {
          cursor: pointer;
        }
      }
      .tougao {
        flex: 2;
        // background-color: thistle;
        display: flex;
        justify-content: space-between;
        align-items: center;
        div {
          height: 36px;
          width: 100%;
          color: white;
          text-align: center;
          line-height: 36px;
          background-color: #fb7299;
          border-radius: 5px;
        }
        div:hover {
          cursor: pointer;
        }
      }
    }
  }
}
.guding {
  position: fixed !important;
  top: 0px;
  left: 0px;
  background-image: linear-gradient(
    to left,
    lime,
    pink,
    orange,
    yellow,
    cyan,
    plum
  );
  color: black !important;
  box-shadow: 0px 0px 10px #f6f9fa;
  border-radius: 5px;
}
</style>